/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!		\file		prpex_color.h
  \date		june 2011
  \author		TNick

  \brief		color class


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read ReadMe.txt and Licence.txt in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __PRPEX_COLOR_INC__
#define __PRPEX_COLOR_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<QColor>
#include	<QString>
#include	"prpmdl.h"
#include	"prptpl.h"


/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

/// class representing a color
/**
*	colors are diffrent from all other types; they are hosting subitems
*	and are the only type allowed at top level
*/
class PEX_Col : public PrpNode		{

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:

	/// this is the value of this item
	QRgb		rgb_value;

	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:

	/// constructor;
	PEX_Col		(
		PrpMdl*		pa_mdl,		/**< father model */
		PrpNode*	pa_fth,		/**< father item; NULL for top level */
		QString		stra_name,	/**< name of entry */
		QString		stra_descr,	/**< description of entry */
		QRgb		init_rgb__col	/**< description of entry */
		);

	/// destructor;
	virtual				~PEX_Col		(void) {}

	/// request actual value in text form
	virtual QVariant		valAsText	(void)
	{	return QString("(%1, %2, %3)")
				.arg(qRed(rgb_value))
				.arg(qGreen(rgb_value))
				.arg(qBlue(rgb_value)); }
	/// request decoration for the value
	virtual	QVariant		valAsDecor	(void)
	{	return QColor(rgb_value); }
	/// request to change the value made by user
	virtual bool			changeVal	(QVariant new_value);
	/// create editor for this type of item
	virtual	QWidget*	editCreate	(
		QWidget *					parent,
		const QStyleOptionViewItem	&option
		);
	/// load data from item to editor
	virtual	void		editLoad	(
		QWidget *					editor
		);
	/// save data from editor to item
	virtual	void		editSave	(
		QWidget *					editor
		);
//	/// update geometry for the editor
//	virtual	void		editResize	(
//		QWidget *					editor,
//		const QStyleOptionViewItem	&option
//		);
	/// informed about a click on associated icon
	virtual void		editIcon	(PrpView * prp_v, QModelIndex the_idx);




	/// returns the value of this entry
	inline QRgb			value		(void)
	{ return rgb_value; }
	/// sets the name of this entry
	inline void			setValue	(QRgb rgb_new_value)
	{ rgb_value = rgb_new_value; }
	/// returns the value of this entry in QColor format
	inline QColor		color		(void)
	{ return QColor(rgb_value); }


	/// used by subordonate to inform parent about a change
	virtual	void		subChanged	(PrpTpl* hot_item);

	/// used by parent item to inform inferiors about a change
	virtual	void		updInferiors (void);




	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class PEX_Col	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __PRPEX_COLOR_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
